package com.water.service.impl;

import com.water.dao.UsUserDao;
import com.water.entity.UsUser;
import com.water.service.UsUserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * (UsUser)表服务实现类
 *
 * @author makejava
 * @since 2020-12-14 19:19:07
 */
@Service("usUserService")
public class UsUserServiceImpl implements UsUserService {
    @Resource
    private UsUserDao usUserDao;

    /**
     * 通过ID查询单条数据
     *
     * @param userno 主键
     * @return 实例对象
     */
    @Override
    public UsUser queryById(String userno) {
        return this.usUserDao.queryById(userno);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<UsUser> queryAllByLimit(int offset, int limit) {
        return this.usUserDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param usUser 实例对象
     * @return 实例对象
     */
    @Override
    public UsUser insert(UsUser usUser) {
        this.usUserDao.insert(usUser);
        return usUser;
    }

    /**
     * 修改数据
     *
     * @param usUser 实例对象
     * @return 实例对象
     */
    @Override
    public UsUser update(UsUser usUser) {
        this.usUserDao.update(usUser);
        return this.queryById(usUser.getUserno());
    }

    /**
     * 通过主键删除数据
     *
     * @param userno 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String userno) {
        return this.usUserDao.deleteById(userno) > 0;
    }

    /**
     * 两张表
     * @param userno
     * @return
     */
    @Override
    public Map<String, Object> queryByno(String userno) {
        return this.usUserDao.queryByno(userno);
    }

    @Override
    public List<Map<String, Object>> queryWater() {
        return usUserDao.queryWater();
    }
}